package org.ym.thread.ui.api;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.ym.basic.base.ApiResult;
import org.ym.thread.application.ThreadCenterDispatch;
import org.ym.thread.ui.payload.ThreadPoolUpdatePayload;

/**
 * @author ym
 */
@Controller
@RequestMapping(name = "线程池仓储管理中心",value = "/threadCenter")
public class ThreadCenterController {
    /**
     * 查询仓储中所有线程池信息
     * @return ApiResult
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public ApiResult queryAll(){
        return ApiResult.ok(ThreadCenterDispatch.getInstance().queryAll());
    }
    /**
     * 查询仓储中某一个线程池信息
     * @return ApiResult
     */
    @RequestMapping("/get")
    @ResponseBody
    public ApiResult get(Long key){
        return ApiResult.ok(ThreadCenterDispatch.getInstance().get(key));
    }
    /**
     * 更新信息
     * @return ApiResult
     */
    @RequestMapping("/update")
    @ResponseBody
    public ApiResult update(ThreadPoolUpdatePayload threadPoolUpdatePayload){
        return ApiResult.ok(ThreadCenterDispatch.getInstance().update(threadPoolUpdatePayload.toCommand()));
    }
}
